/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lcfgly.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;

/**
 * 文件工具类
 * @author lcfgly
 */
public class FileInfoUtil {
    
    /**
     * 获取资源文件输入流
     * @param filepath
     * @return
     * @throws IOException 
     */
    public static InputStream GetFileInputStream(String filepath) throws IOException{
        DefaultResourceLoader resourceloader=new DefaultResourceLoader();
        Resource resource=  resourceloader.getResource(filepath);
        return resource.getInputStream();
    }
    
    /**
     * 获取一个解析好的properties配置文件数据
     * @param filepath
     * @return
     * @throws IOException 
     */
    public static Properties GetProperties(String filepath) throws IOException{
        Properties properties=new Properties();
        properties.load(GetFileInputStream(filepath));
        return properties;
    }
    
}
